home *** CD-ROM | disk | FTP | other *** search
/ Delphi 5 for Professionals / DELPHI5.iso / Runimage / Delphi50 / Source / Property Editors / bdereg.pas < prev    next >
Encoding:
Pascal/Delphi Source File  |  1999-08-11  |  52.2 KB  |  1,878 lines

  1. unit BDEReg;
  2.  
  3. interface
  4.  
  5. uses
  6.  
  7.   Report, RSConsts, LibHelp, Dialogs, DBLookup, FileCtrl,
  8.  
  9.   SysUtils, Classes, DSDesign, Menus, DBTables, DB, DRIntf, LibIntf, DsnDBCst,
  10.   DSAttrS, DSAttrA, DBReg, DbXPlor, BDEConst, GQEDelph, ColnEdit, TblDsgn,
  11.   DsgnIntf, DBEdit, IxEdit, UpdSqlEd, FldLinks, CnColEdt, DRTable,
  12.   CustomModuleEditors,
  13.   ParentageSupport, DsnDB,
  14.   ModelViews, ModelPrimitives, DataModelViews, DataModelSupport;
  15.  
  16. type
  17.  
  18. { TTableFieldLinkProperty }
  19.  
  20.   TTableFieldLinkProperty = class(TFieldLinkProperty)
  21.   private
  22.     FTable: TTable;
  23.   protected
  24.     procedure GetFieldNamesForIndex(List: TStrings); override;
  25.     function GetIndexBased: Boolean; override;
  26.     function GetIndexDefs: TIndexDefs; override;
  27.     function GetIndexFieldNames: string; override;
  28.     function GetIndexName: string; override;
  29.     function GetMasterFields: string; override;
  30.     procedure SetIndexFieldNames(const Value: string); override;
  31.     procedure SetIndexName(const Value: string); override;
  32.     procedure SetMasterFields(const Value: string); override;
  33.   public
  34.     property IndexBased: Boolean read GetIndexBased;
  35.     property IndexDefs: TIndexDefs read GetIndexDefs;
  36.     property IndexFieldNames: string read GetIndexFieldNames write SetIndexFieldNames;
  37.     property IndexName: string read GetIndexName write SetIndexName;
  38.     property MasterFields: string read GetMasterFields write SetMasterFields;
  39.  
  40.     procedure Edit; override;
  41.   end;
  42.  
  43. const
  44.   cDefaultSessionSprigName =    '<DefaultSession>'; { do not localize }
  45.   cImpliedSessionSprigPrefix =  '<ImpliedSession>'; { do not localize }
  46.   cImpliedDatabaseSprigPrefix = '<ImpliedDatabase>'; { do not localize }
  47.  
  48. type
  49.   TSessionSprig = class(TSprigAtRoot)
  50.   public
  51.     function Name: string; override;
  52.     function Caption: string; override;
  53.     function AnyProblems: Boolean; override;
  54.   end;
  55.  
  56.   TDefaultSessionSprig = class(TSprigAtRoot)
  57.   public
  58.     function UniqueName: string; override;
  59.     function Caption: string; override;
  60.     function Transient: Boolean; override;
  61.     function ItemClass: TClass; override;
  62.   end;
  63.  
  64.   TImpliedSessionSprig = class(TSprigAtRoot)
  65.   private
  66.     FSessionName: string;
  67.   public
  68.     function UniqueName: string; override;
  69.     function Caption: string; override;
  70.     function Transient: Boolean; override;
  71.     function ItemClass: TClass; override;
  72.   end;
  73.  
  74.   TDatabaseSprig = class(TSprig)
  75.   public
  76.     function Name: string; override;
  77.     function Caption: string; override;
  78.     function AnyProblems: Boolean; override;
  79.     procedure FigureParent; override;
  80.     function DragDropTo(AItem: TSprig): Boolean; override;
  81.     function DragOverTo(AItem: TSprig): Boolean; override;
  82.     class function PaletteOverTo(AParent: TSprig; AClass: TClass): Boolean; override;
  83.   end;
  84.  
  85.   TImpliedDatabaseSprig = class(TSprig)
  86.   private
  87.     FSessionName: string;
  88.     FAlias: string;
  89.   public
  90.     function AnyProblems: Boolean; override;
  91.     function UniqueName: string; override;
  92.     function Caption: string; override;
  93.     function Transient: Boolean; override;
  94.     function ItemClass: TClass; override;
  95.     procedure FigureParent; override;
  96.     function DragDropTo(AItem: TSprig): Boolean; override;
  97.     function DragOverTo(AItem: TSprig): Boolean; override;
  98.   end;
  99.  
  100.   TBatchMoveSprig = class(TSprigAtRoot)
  101.   public
  102.     function AnyProblems: Boolean; override;
  103.     function Caption: string; override;
  104.   end;
  105.  
  106.   TUpdateSQLSprig = class(TSprigAtRoot)
  107.   public
  108.     function AnyProblems: Boolean; override;
  109.   end;
  110.  
  111.   TBDEDataSetSprig = class(TDataSetSprig)
  112.   public
  113.     function GetDSDesignerClass: TDSDesignerClass; override;
  114.   end;
  115.  
  116.   TNestedTableSprig = class(TBDEDataSetSprig)
  117.   public
  118.     class function ParentProperty: string; override;
  119.   end;
  120.  
  121.   TDBDataSetSprig = class(TBDEDataSetSprig)
  122.   public
  123.     function AnyProblems: Boolean; override;
  124.     procedure FigureParent; override;
  125.     procedure Reparent; override;
  126.     function DragDropTo(AItem: TSprig): Boolean; override;
  127.     function DragOverTo(AItem: TSprig): Boolean; override;
  128.     class function PaletteOverTo(AParent: TSprig; AClass: TClass): Boolean; override;
  129.   end;
  130.  
  131.   TTableSprig = class(TDBDataSetSprig)
  132.   public
  133.     function AnyProblems: Boolean; override;
  134.     function Caption: string; override;
  135.   end;
  136.  
  137.   TQuerySprig = class(TDBDataSetSprig)
  138.   public
  139.     function AnyProblems: Boolean; override;
  140.   end;
  141.  
  142.   TStoredProcSprig = class(TDBDataSetSprig)
  143.   public
  144.     function AnyProblems: Boolean; override;
  145.     function Caption: string; override;
  146.   end;
  147.  
  148.   TBDEDataSetIsland = class(TDataSetIsland)
  149.   end;
  150.  
  151.   TDBDataSetIsland = class(TBDEDataSetIsland)
  152.   end;
  153.  
  154.   TTableIsland = class(TDBDataSetIsland)
  155.   end;
  156.  
  157.   TTableMasterDetailBridge = class(TMasterDetailBridge)
  158.   public
  159.     function CanEdit: Boolean; override;
  160.     class function OmegaIslandClass: TIslandClass; override;
  161.     class function GetOmegaSource(AItem: TPersistent): TDataSource; override;
  162.     class procedure SetOmegaSource(AItem: TPersistent; ADataSource: TDataSource); override;
  163.     function Caption: string; override;
  164.     function Edit: Boolean; override;
  165.   end;
  166.  
  167.   TQueryIsland = class(TDBDataSetIsland)
  168.   end;
  169.  
  170.   TQueryMasterDetailBridge = class(TMasterDetailBridge)
  171.   public
  172.     class function RemoveMasterFieldsAsWell: Boolean; override;
  173.     class function OmegaIslandClass: TIslandClass; override;
  174.     class function GetOmegaSource(AItem: TPersistent): TDataSource; override;
  175.     class procedure SetOmegaSource(AItem: TPersistent; ADataSource: TDataSource); override;
  176.     function Caption: string; override;
  177.   end;
  178.  
  179. function SprigBDESessionName(const AName: string): string;
  180. function SprigBDEImpliedDatabaseName(const AName: string): string;
  181. function SprigBDEImpliedSessionName(const AName: string): string;
  182.  
  183. procedure Register;
  184.  
  185. implementation
  186.  
  187. type
  188.  
  189. { TBDEDesigner }
  190.  
  191.   TMenuItemID = (miSeparator, miRetrieve, miSave, miSaveAs, miAssociate, miUnassociate);
  192.  
  193.   TBDEDesigner = class(TDSDesigner)
  194.   private
  195.     FTableID: TTableID;
  196.     FQueryDescs: TQueryDescription;
  197.     FMenuArray: array [TMenuItemID] of TMenuItem;
  198.   protected
  199.     procedure AttributeClick(Sender: TObject);
  200.     function QualifyTableName(DatabaseName: string;
  201.       Database: TDatabase; const TableName: string): string;
  202.     function CheckAttribute(Field: TField): Boolean;
  203.     procedure GetTableDesc(var ADatabase, ATable: string);
  204.     procedure GetFieldInfo(Field: TField; var FieldID: TFieldID;
  205.       var AttrID: TAttrID);
  206.     function FindFieldInfo(Field: TField; var FieldID: TFieldID;
  207.       var AttrID: TAttrID): Boolean;
  208.     function RetrieveAttributes(Field: TField): Boolean;
  209.     function SaveAttributes(Field: TField): Boolean;
  210.     function SaveAttributesAs(Field: TField): Boolean;
  211.     function AssociateAttributes(Field: TField): Boolean;
  212.     function UnassociateAttributes(Field: TField): Boolean;
  213.   public
  214.     destructor Destroy; override;
  215.     procedure BeginCreateFields; override;
  216.     function DoCreateField(const FieldName: string; Origin: string): TField; override;
  217.     procedure EndCreateFields; override;
  218.     function GetControlClass(Field: TField): string; override;
  219.     procedure InitializeMenu(Menu: TPopupMenu); override;
  220.     procedure UpdateMenus(Menu: TPopupMenu; EditState: TEditState); override;
  221.   end;
  222.  
  223. destructor TBDEDesigner.Destroy;
  224. begin
  225.   inherited Destroy;
  226.   if DSDesign.DesignerCount <= 0 then DictionaryDeactivate;
  227. end;
  228.  
  229. function TBDEDesigner.QualifyTableName(DatabaseName: string;
  230.   Database: TDatabase; const TableName: string): string;
  231. begin
  232.   if not Assigned(Database) then
  233.     Result := QualifyTableNameByName(TDBDataset(Dataset).SessionName,
  234.       DatabaseName, TableName) else
  235.     Result := DrIntf.QualifyTableName(Database, TableName);
  236. end;
  237.  
  238. procedure TBDEDesigner.GetTableDesc(var ADatabase, ATable: string);
  239. var
  240.   Database: TDatabase;
  241. begin
  242.   ADatabase := '';
  243.   ATable := '';
  244.   if Dataset is TTable then
  245.   begin
  246.     ADatabase := TTable(Dataset).DatabaseName;
  247.     Database := TTable(Dataset).Database;
  248.     ATable := QualifyTableName(ADatabase, Database, TTable(Dataset).TableName);
  249.   end;
  250. end;
  251.  
  252. function TBDEDesigner.CheckAttribute(Field: TField): Boolean;
  253. var
  254.   FieldID: TFieldID;
  255.   AttrID: TAttrID;
  256. begin
  257.   Result := False;
  258.   if Field.AttributeSet <> '' then Exit;
  259.   FindFieldInfo(Field, FieldID, AttrID);
  260.   if not IsNullID(AttrID) then Exit;
  261.   Result := True;
  262. end;
  263.  
  264. procedure TBDEDesigner.GetFieldInfo(Field: TField; var FieldID: TFieldID;
  265.   var AttrID: TAttrID);
  266. begin
  267.   if not FindFieldInfo(Field, FieldID, AttrID) then
  268.     raise Exception.CreateResFmt(@SDSFieldNotInDict, [Field.FullName]);
  269. end;
  270.  
  271. function TBDEDesigner.FindFieldInfo(Field: TField; var FieldID: TFieldID;
  272.   var AttrID: TAttrID): Boolean;
  273. var
  274.   DatabaseName, TableName: string;
  275. begin
  276.   GetTableDesc(Databasename, TableName);
  277.   AttrID := NullAttrID;
  278.   FieldID := FindFieldID(FindTableID(FindDatabaseID(DatabaseName), TableName),
  279.     Field.FieldName);
  280.   if not IsNullID(FieldID) then
  281.     AttrID := GetAttrID(FieldID)
  282.   else if Field.AttributeSet <> '' then
  283.     AttrID := FindAttrID(Field.AttributeSet);
  284.   Result := not IsNullID(FieldID) or not IsNullID(AttrID);
  285. end;
  286.  
  287. function TBDEDesigner.RetrieveAttributes(Field: TField): Boolean;
  288. var
  289.   FieldID: TFieldID;
  290.   AttrID: TAttrID;
  291. begin
  292.   if FindFieldInfo(Field, FieldID, AttrID) then
  293.   begin
  294.     UpdateField(Field, FieldID, AttrID);
  295.     Field.AttributeSet := GetAttrName(AttrID);
  296.   end;
  297.   Result := True;
  298. end;
  299.  
  300. function TBDEDesigner.SaveAttributes(Field: TField): Boolean;
  301. var
  302.   FieldID: TFieldID;
  303.   AttrID: TAttrID;
  304. begin
  305.   Result := True;
  306.   GetFieldInfo(Field, FieldID, AttrID);
  307.   if not IsNullID(AttrID) then
  308.     UpdateAttr(Field, FieldID, AttrID)
  309.   else
  310.     Result := SaveAttributesAs(Field);
  311. end;
  312.  
  313. function TBDEDesigner.SaveAttributesAs(Field: TField): Boolean;
  314. var
  315.   DatabaseName, TableName, AttributeName: string;
  316.   FieldID: TFieldID;
  317.   AttrID: TAttrID;
  318. begin
  319.   GetTableDesc(DatabaseName, TableName);
  320.   GetFieldInfo(Field, FieldID, AttrID);
  321.   Result := SaveAttributesAsDlg(TableName, Field.FieldName, AttributeName, AttrID);
  322.   if Result then NewAttr(Field, FieldID, AttributeName, AttrID);
  323. end;
  324.  
  325. function TBDEDesigner.AssociateAttributes(Field: TField): Boolean;
  326. var
  327.   FieldID: TFieldID;
  328.   AttrID: TAttrID;
  329. begin
  330.   FindFieldInfo(Field, FieldID, AttrID);
  331.   if GetAssociateAttributes(AttrID, Result) then
  332.   begin
  333.     if not IsNullID(FieldID) then AssociateAttr(AttrID, FieldID);
  334.     UpdateField(Field, FieldID, AttrID);
  335.     Field.AttributeSet := GetAttrName(AttrID);
  336.   end;
  337. end;
  338.  
  339. function TBDEDesigner.UnassociateAttributes(Field: TField): Boolean;
  340. var
  341.   FieldID: TFieldID;
  342.   AttrID: TAttrID;
  343. begin
  344.   Field.AttributeSet := '';
  345.   FindFieldInfo(Field, FieldID, AttrID);
  346.   if not IsNullID(FieldID) then UnassociateAttr(FieldID);
  347.   Field.AttributeSet := '';
  348.   Result := True;
  349. end;
  350.  
  351. procedure TBDEDesigner.AttributeClick(Sender: TObject);
  352. var
  353.   MenuID: TMenuItemID;
  354.   Proc: TSelectionProc;
  355. begin
  356.   if Assigned(Sender) and (Sender is TComponent) then
  357.     MenuID := TMenuItemID(TComponent(Sender).Tag) else
  358.     MenuID := miSeparator;
  359.   try
  360.     case MenuID of
  361.       miRetrieve: Proc := RetrieveAttributes;
  362.       miSave: Proc := SaveAttributes;
  363.       miSaveAs: Proc := SaveAttributesAs;
  364.       miAssociate: Proc := AssociateAttributes;
  365.       miUnassociate: Proc := UnassociateAttributes;
  366.     else
  367.       Proc := nil;
  368.     end;
  369.     if Assigned(Proc) then
  370.       FieldsEditor.ForEachSelection(Proc);
  371.   finally
  372.     if MenuID in [miAssociate, miRetrieve] then
  373.       FieldsEditor.Designer.Modified;
  374.   end;
  375. end;
  376.  
  377. function TBDEDesigner.GetControlClass(Field: TField): string;
  378. var
  379.   FieldID: TFieldID;
  380.   AttrId: TAttrID;
  381. begin
  382.   if Assigned(Field) then
  383.   begin
  384.     FindFieldInfo(Field, FieldID, AttrID);
  385.     Result := DRIntf.GetControlClass(AttrID);
  386.   end else
  387.     Result := '';
  388.   if Result = '' then
  389.     Result := inherited GetControlClass(Field);
  390. end;
  391.  
  392. procedure TBDEDesigner.BeginCreateFields;
  393. var
  394.   DatabaseName, TableName: string;
  395. begin
  396.   if Dataset is TTable then
  397.   begin
  398.     GetTableDesc(DatabaseName, TableName);
  399.     FTableID := FindTableID(FindDatabaseID(DatabaseName), TableName);
  400.   end
  401.   else
  402.   if Dataset is TQuery then
  403.   begin
  404.     FQueryDescs := TQueryDescription.Create(nil);
  405.     try
  406.       FQueryDescs.Query := TQuery(Dataset);
  407.       FQueryDescs.Open;
  408.     except
  409.       FQueryDescs.Free;
  410.       FQueryDescs := nil;
  411.     end;
  412.   end;
  413.   inherited BeginCreateFields;
  414. end;
  415.  
  416. procedure TBDEDesigner.EndCreateFields;
  417. begin
  418.   FQueryDescs.Free;
  419.   FQueryDescs := nil;
  420.   FTableID := NullTableId;
  421.   inherited EndCreateFields;
  422. end;
  423.  
  424. function TBDEDesigner.DoCreateField(const FieldName: string; Origin: string): TField;
  425. var
  426.   FieldID: TFieldID;
  427.   AttrID: TAttrID;
  428.   DatabaseName: string;
  429.   TableName: string;
  430.   FldName: string;
  431.  
  432.   function NeedsBackslashing(const Name: string): Boolean;
  433.   var
  434.     N: PChar;
  435.   begin
  436.     Result := True;
  437.     N := PChar(Pointer(Name));
  438.     while N^ <> #0 do
  439.       if N^ in ['\','"'] then Exit
  440.       else if N^ in LeadBytes then Inc(N, 2)
  441.       else Inc(N);
  442.     Result := False;
  443.   end;
  444.  
  445.   function Backslash(const Name: string): string;
  446.   var
  447.     CName: array[0..1024] of Char;
  448.     N, C: PChar;
  449.   begin
  450.     N := PChar(Pointer(Name));
  451.     C := CName;
  452.     while N^ <> #0 do
  453.     begin
  454.       if N^ in ['\', '"'] then
  455.       begin
  456.         C^ := '\';
  457.         Inc(C);
  458.       end;
  459.       C^ := N^;
  460.       if N^ in LeadBytes then
  461.       begin
  462.         Inc(C);
  463.         Inc(N);
  464.         C^ := N^;
  465.       end;
  466.       Inc(C);
  467.       Inc(N);
  468.     end;
  469.     SetString(Result, CName, C - CName);
  470.   end;
  471.  
  472.   function Delimit(const Name: string): string;
  473.   begin
  474.     Result := Name;
  475.     if NeedsBackslashing(Result) then Result := Backslash(Result);
  476.     if Pos('.', Name) <> 0 then Result := '"' + Result + '"';
  477.   end;
  478.  
  479. begin
  480.   FieldID := NullFieldID;
  481.   AttrID := NullAttrID;
  482.   if Origin = '' then
  483.   begin
  484.     if DataSet is TTable then
  485.     begin
  486.       FieldID := FindFieldID(FTableID, FieldName);
  487.       AttrID := GetAttrID(FieldID);
  488.       Origin := '';
  489.     end else
  490.     if DataSet is TQuery then
  491.     try
  492.       FQueryDescs.RecNo := DataSet.FieldDefs.Find(FieldName).FieldNo;
  493.       DatabaseName := FQueryDescs['DATABASE']; { Do not localize }
  494.       TableName := FQueryDescs['TABLENAME']; { Do not localize }
  495.       FldName := FQueryDescs['FIELDNAME']; { Do not localize }
  496.       FieldID := FindFieldID(FindTableID(FindDatabaseID(DatabaseName),
  497.         QualifyTableName(DatabaseName, nil, FQueryDescs['TABLENAME'])), { Do not localize }
  498.         FQueryDescs['FIELDNAME']); { Do not localize }
  499.       AttrID := GetAttrID(FieldID);
  500.       Origin := Delimit(TableName) + '.' + Delimit(FldName);
  501.       if (TQuery(Dataset).Database = nil) or
  502.          AnsiSameText(TQuery(Dataset).DatabaseName, DatabaseName) then
  503.         Origin := Delimit(DatabaseName) + '.' + Origin;
  504.     except
  505.       FieldID := NullFieldID;
  506.       AttrID := NullAttrID;
  507.       Origin := '';
  508.     end;
  509.   end;
  510.   Result := inherited DoCreateField(FieldName, Origin);
  511.   try
  512.     if DictionaryActive then UpdateField(Result, FieldID, AttrID);
  513.   except
  514.     Result.Free;
  515.     raise;
  516.   end;
  517. end;
  518.  
  519. procedure TBDEDesigner.InitializeMenu(Menu: TPopupMenu);
  520. type
  521.   TMenuInfo = record
  522.     Name: string;
  523.     HelpContext: Integer;
  524.     Caption: string;
  525.     ShortCut: string;
  526.     Tag: TMenuItemID;
  527.   end;
  528. const
  529.   AttributeMenus: array[TMenuItemID] of TMenuInfo = (
  530.    (Name: 'N2'; HelpContext: 0; Caption: '-'; ShortCut: ''; Tag: miSeparator), { Do not localize }
  531.    (Name: 'RetrieveItem'; HelpContext: 30138; Caption: SRetrieveAttributes;{ Do not localize }
  532.     ShortCut: 'Ctrl+R'; Tag: miRetrieve),{ Do not localize }
  533.    (Name: 'UpdateItem'; HelpContext: 30139; Caption: SSaveAttributes;{ Do not localize }
  534.     ShortCut: 'Ctrl+S'; Tag: miSave),{ Do not localize }
  535.    (Name: 'SaveAttributesAsItem'; HelpContext: 30140; Caption: SSaveAttributesAs;{ Do not localize }
  536.     ShortCut: 'Ctrl+E'; Tag: miSaveAs),{ Do not localize }
  537.    (Name: 'AssociateItem'; HelpContext: 30141; Caption: SAssociateAttributes;{ Do not localize }
  538.     ShortCut: 'Ctrl+O'; Tag: miAssociate),{ Do not localize }
  539.    (Name: 'Unassociate'; HelpContext: 30142; Caption: SUnassociateAttributes;{ Do not localize }
  540.     ShortCut: 'Ctrl+U'; Tag: miUnassociate){ Do not localize }
  541.   );
  542. var
  543.   i: TMenuItemID;
  544. begin
  545.   FTableID := NullTableID;
  546.   FQueryDescs := nil;
  547.   inherited InitializeMenu(Menu);
  548.   for i := Low(AttributeMenus) to High(AttributeMenus) do
  549.   begin
  550.     FMenuArray[i] := TMenuItem.Create(nil);
  551.     FMenuArray[i].Name := AttributeMenus[i].Name;
  552.     FMenuArray[i].HelpContext := AttributeMenus[i].HelpContext;
  553.     FMenuArray[i].Caption := AttributeMenus[i].Caption;
  554.     if AttributeMenus[i].ShortCut <> '' then
  555.       FMenuArray[i].ShortCut := TextToShortCut(AttributeMenus[i].ShortCut);
  556.     FMenuArray[i].Tag := Integer(AttributeMenus[i].Tag);
  557.     FMenuArray[i].OnClick := AttributeClick;
  558.     Menu.Items.Add(FMenuArray[i]);
  559.   end;
  560. end;
  561.  
  562. procedure TBDEDesigner.UpdateMenus(Menu: TPopupMenu; EditState: TEditState);
  563. var
  564.   i: TMenuItemID;
  565.   Active: Boolean;
  566.   HasAttributes: Boolean;
  567.   Update: Boolean;
  568.   HasSelection: Boolean;
  569. begin
  570.   inherited UpdateMenus(Menu, EditState);
  571.   HasSelection := esCanCopy in EditState;
  572.   Active := DictionaryActive;
  573.   Update := HasSelection and Active;
  574.   HasAttributes := HasSelection and Update and not FieldsEditor.ForEachSelection(CheckAttribute);
  575.   for i := Low(FMenuArray) to High(FMenuArray) do
  576.     if Assigned(FMenuArray[i]) then
  577.       case i of
  578.         miRetrieve: FMenuArray[i].Enabled := HasSelection and Active;
  579.         miSave: FMenuArray[i].Enabled := HasAttributes;
  580.         miSaveAs: FMenuArray[i].Enabled := HasAttributes or (Update and (DataSet is TTable));
  581.         miAssociate: FMenuArray[i].Enabled := Update;
  582.         miUnassociate: FMenuArray[i].Enabled := HasAttributes;
  583.       end;
  584. end;
  585.  
  586. { TDBDataSetEditor }
  587.  
  588. type
  589.   TDBDataSetEditor = class(TDataSetEditor)
  590.   protected
  591.     function GetDSDesignerClass: TDSDesignerClass; override;
  592.   public
  593.     procedure ExecuteVerb(Index: Integer); override;
  594.     function GetVerb(Index: Integer): string; override;
  595.     function GetVerbCount: Integer; override;
  596.   end;
  597.  
  598. function TDBDataSetEditor.GetDSDesignerClass: TDSDesignerClass;
  599. begin
  600.   Result := TBDEDesigner;
  601. end;
  602.  
  603. procedure TDBDataSetEditor.ExecuteVerb(Index: Integer);
  604. begin
  605.   if Index <= inherited GetVerbCount - 1 then
  606.     inherited ExecuteVerb(Index) else
  607.   begin
  608.     Dec(Index, inherited GetVerbCount);
  609.     case Index of
  610.       0: ExploreDataset(TDBDataset(Component));
  611.     end;
  612.   end;
  613. end;
  614.  
  615. function TDBDataSetEditor.GetVerb(Index: Integer): string;
  616. begin
  617.   if Index <= inherited GetVerbCount - 1 then
  618.     Result := inherited GetVerb(Index) else
  619.   begin
  620.     Dec(Index, inherited GetVerbCount);
  621.     case Index of
  622.       0: Result := SExplore;
  623.     end;
  624.   end;
  625. end;
  626.  
  627. function TDBDataSetEditor.GetVerbCount: Integer;
  628. begin
  629.   Result := inherited GetVerbCount + 1;
  630. end;
  631.  
  632. { TQueryEditor }
  633.  
  634. type
  635.   TQueryEditor = class(TDBDataSetEditor)
  636.   public
  637.     procedure ExecuteVerb(Index: Integer); override;
  638.     function GetVerb(Index: Integer): string; override;
  639.     function GetVerbCount: Integer; override;
  640.   end;
  641.  
  642. procedure TQueryEditor.ExecuteVerb(Index: Integer);
  643. var
  644.   Database: TDatabase;
  645.   Query: TQuery;
  646. begin
  647.   if Index < inherited GetVerbCount then
  648.     inherited ExecuteVerb(Index) else
  649.   begin
  650.     Query := Component as TQuery;
  651.     Dec(Index, inherited GetVerbCount);
  652.     case Index of
  653.       0: Query.ExecSQL;
  654.       1:
  655.       if GQELoaded then
  656.       begin
  657.         Database := Query.OpenDatabase;
  658.         try
  659.           BuildQuery(Query);
  660.         finally
  661.           Query.CloseDatabase(Database);
  662.         end;
  663.         if Designer <> nil then Designer.Modified;
  664.       end;
  665.     end;
  666.   end;
  667. end;
  668.  
  669. function TQueryEditor.GetVerb(Index: Integer): string;
  670. begin
  671.   if Index < inherited GetVerbCount then
  672.     Result := inherited GetVerb(Index) else
  673.   begin
  674.     Dec(Index, inherited GetVerbCount);
  675.     case Index of
  676.       0: Result := SExecute;
  677.       1: if GQELoaded then Result := SGQEVerb;
  678.     end;
  679.   end;
  680. end;
  681.  
  682. function TQueryEditor.GetVerbCount: Integer;
  683. begin
  684.   Result := inherited GetVerbCount + 1 + Ord(LoadGQE);
  685. end;
  686.  
  687. { TQueryParamsProperty }
  688.  
  689. type
  690.   TQueryParamsProperty = class(TCollectionProperty)
  691.   public
  692.     function GetColOptions: TColOptions; override;
  693.   end;
  694.  
  695. function TQueryParamsProperty.GetColOptions: TColOptions;
  696. begin
  697.   Result := [];
  698. end;
  699.  
  700. { TStoredProcEditor }
  701.  
  702. type
  703.   TStoredProcEditor = class(TDBDataSetEditor)
  704.   public
  705.     procedure ExecuteVerb(Index: Integer); override;
  706.     function GetVerb(Index: Integer): string; override;
  707.     function GetVerbCount: Integer; override;
  708.   end;
  709.  
  710. procedure TStoredProcEditor.ExecuteVerb(Index: Integer);
  711. begin
  712.   if Index < inherited GetVerbCount then
  713.     inherited ExecuteVerb(Index) else
  714.   begin
  715.     Dec(Index, inherited GetVerbCount);
  716.     if Index = 0 then (Component as TStoredProc).ExecProc;
  717.   end;
  718. end;
  719.  
  720. function TStoredProcEditor.GetVerb(Index: Integer): string;
  721. begin
  722.   if Index < inherited GetVerbCount then
  723.     Result := inherited GetVerb(Index) else
  724.   begin
  725.     Dec(Index, inherited GetVerbCount);
  726.     if Index = 0 then Result := SExecute;
  727.   end;
  728. end;
  729.  
  730. function TStoredProcEditor.GetVerbCount: Integer;
  731. begin
  732.   Result := inherited GetVerbCount + 1;
  733. end;
  734.  
  735. { TStoredProcParamsProperty }
  736.  
  737. type
  738.   TStoredProcParamsProperty = class(TCollectionProperty)
  739.   public
  740.     procedure Edit; override;
  741.   end;
  742.  
  743. procedure TStoredProcParamsProperty.Edit;
  744. var
  745.   StoredProc: TStoredProc;
  746.   Params: TParams;
  747. begin
  748.   StoredProc := (GetComponent(0) as TStoredProc);
  749.   Params := TParams.Create(nil);
  750.   try
  751.     StoredProc.CopyParams(Params);
  752.   finally
  753.     Params.Free;
  754.   end;
  755.   inherited Edit;
  756. end;
  757.  
  758. { TTableEditor }
  759.  
  760. function IsDatabaseOpen(DataSet: TDBDataSet): Boolean;
  761. var
  762.   Session: TSession;
  763.   DB: TDatabase;
  764. begin
  765.   Result := False;
  766.   with DataSet do
  767.   begin
  768.     Session := Sessions.FindSession(SessionName);
  769.     if Session <> nil then
  770.     begin
  771.       DB := Session.FindDatabase(DatabaseName);
  772.       Result := (DB <> nil) and DB.Connected;
  773.     end;
  774.   end;
  775. end;
  776.  
  777. type
  778.   TTableEditor = class(TDBDataSetEditor)
  779.   private
  780.     FActions: TTableDesignActions;
  781.     procedure UpdateActions;
  782.     function IndexToAction(Index: Integer): TTableDesignAction;
  783.   public
  784.     procedure ExecuteVerb(Index: Integer); override;
  785.     function GetVerb(Index: Integer): string; override;
  786.     function GetVerbCount: Integer; override;
  787.   end;
  788.  
  789. procedure TTableEditor.UpdateActions;
  790. const
  791.   ExistsActions: array [Boolean] of TTableDesignActions =
  792.     ([tdCreate, tdUpdate], [tdDelete, tdUpdate, tdRename]);
  793. begin
  794.   FActions := [];
  795.   if IsDatabaseOpen(TTable(Component)) then
  796.   try
  797.     FActions := ExistsActions[TTable(Component).Exists];
  798.     if (tdCreate in FActions) and (TTable(Component).FieldDefs.Count = 0) then
  799.       Exclude(FActions, tdCreate);
  800.     if (tdUpdate in FActions) and (TTable(Component).TableName = '') then
  801.       Exclude(FActions, tdUpdate);
  802.   except
  803.   end;
  804. end;
  805.  
  806. function TTableEditor.IndexToAction(Index: Integer): TTableDesignAction;
  807. begin
  808.   for Result := Low(TTableDesignAction) to High(TTableDesignAction) do
  809.     if Result in FActions then if Index = 0 then Exit else Dec(Index);
  810.   Result := tdCreate; // Error
  811. end;
  812.  
  813. procedure TTableEditor.ExecuteVerb(Index: Integer);
  814. var
  815.   I: Integer;
  816. begin
  817.   I := inherited GetVerbCount;
  818.   if Index < I then inherited
  819.   else if TableDesigner(TTable(Component), IndexToAction(Index - I)) then
  820.     Designer.Modified;
  821. end;
  822.  
  823. function TTableEditor.GetVerb(Index: Integer): string;
  824. var
  825.   I: Integer;
  826. begin
  827.   I := inherited GetVerbCount;
  828.   if Index < I then
  829.     Result := inherited GetVerb(Index) else
  830.     Result := TableDesignMenu[IndexToAction(Index - I)];
  831. end;
  832.  
  833. function TTableEditor.GetVerbCount: Integer;
  834. var
  835.   T: TTableDesignAction;
  836. begin
  837.   Result := inherited GetVerbCount;
  838.   UpdateActions;
  839.   for T := Low(TableDesignMenu) to High(TableDesignMenu) do
  840.     if T in FActions then Inc(Result);
  841. end;
  842.  
  843. { TDatabaseEditor }
  844.  
  845. type
  846.   TDatabaseEditor = class(TComponentEditor)
  847.   public
  848.     procedure ExecuteVerb(Index: Integer); override;
  849.     function GetVerb(Index: Integer): string; override;
  850.     function GetVerbCount: Integer; override;
  851.   end;
  852.  
  853. procedure TDatabaseEditor.ExecuteVerb(Index: Integer);
  854. begin
  855.   case Index of
  856.     0: if EditDatabase(TDatabase(Component)) then Designer.Modified;
  857.     1: ExploreDatabase(TDatabase(Component));
  858.   end;
  859. end;
  860.  
  861. function TDatabaseEditor.GetVerb(Index: Integer): string;
  862. begin
  863.   case Index of
  864.     0: Result := SDatabaseEditor;
  865.     1: Result := SExplore;
  866.   end;
  867. end;
  868.  
  869. function TDatabaseEditor.GetVerbCount: Integer;
  870. begin
  871.   Result := 2;
  872. end;
  873.  
  874. { TBatchMoveEditor }
  875.  
  876. type
  877.   TBatchMoveEditor = class(TDefaultEditor)
  878.   public
  879.     procedure ExecuteVerb(Index: Integer); override;
  880.     function GetVerb(Index: Integer): string; override;
  881.     function GetVerbCount: Integer; override;
  882.   end;
  883.  
  884. procedure TBatchMoveEditor.ExecuteVerb(Index: Integer);
  885. begin
  886.   TBatchMove(Component).Execute;
  887. end;
  888.  
  889. function TBatchMoveEditor.GetVerb(Index: Integer): string;
  890. begin
  891.   Result := SBatchExecute;
  892. end;
  893.  
  894. function TBatchMoveEditor.GetVerbCount: Integer;
  895. begin
  896.   Result := 1;
  897. end;
  898.  
  899. { TSessionNameProperty }
  900.  
  901. type
  902.   TSessionNameProperty = class(TDBStringProperty)
  903.   public
  904.     procedure GetValueList(List: TStrings); override;
  905.   end;
  906.  
  907. procedure TSessionNameProperty.GetValueList(List: TStrings);
  908. begin
  909.   Sessions.GetSessionNames(List);
  910. end;
  911.  
  912. { TDatabaseNameProperty }
  913.  
  914. type
  915.   TDatabaseNameProperty = class(TDBStringProperty)
  916.   public
  917.     procedure GetValueList(List: TStrings); override;
  918.   end;
  919.  
  920. procedure TDatabaseNameProperty.GetValueList(List: TStrings);
  921. begin
  922.   (GetComponent(0) as TDBDataSet).DBSession.GetDatabaseNames(List);
  923. end;
  924.  
  925. { TAliasNameProperty }
  926.  
  927. type
  928.   TAliasNameProperty = class(TDBStringProperty)
  929.   public
  930.     procedure GetValueList(List: TStrings); override;
  931.   end;
  932.  
  933. procedure TAliasNameProperty.GetValueList(List: TStrings);
  934. begin
  935.   (GetComponent(0) as TDatabase).Session.GetAliasNames(List);
  936. end;
  937.  
  938. { TDriverNameProperty }
  939.  
  940. type
  941.   TDriverNameProperty = class(TDBStringProperty)
  942.   public
  943.     procedure GetValueList(List: TStrings); override;
  944.   end;
  945.  
  946. procedure TDriverNameProperty.GetValueList(List: TStrings);
  947. begin
  948.   (GetComponent(0) as TDatabase).Session.GetDriverNames(List);
  949. end;
  950.  
  951. { TTableNameProperty }
  952.  
  953. type
  954.   TTableNameProperty = class(TDBStringProperty)
  955.   public
  956.     function AutoFill: Boolean; override;
  957.     procedure GetValueList(AList: TStrings); override;
  958.   end;
  959.  
  960. function TTableNameProperty.AutoFill: Boolean;
  961. begin
  962.   Result := IsDatabaseOpen(GetComponent(0) as TDBDataSet);
  963. end;
  964.  
  965. procedure TTableNameProperty.GetValueList(AList: TStrings);
  966. const
  967.   Masks: array[TTableType] of string[5] = ('', '*.DB', '*.DBF', '*.DBF', '*.TXT'); { Do not localize }
  968. begin
  969.   with GetComponent(0) as TTable do
  970.     DBSession.GetTableNames(DatabaseName, Masks[TableType],
  971.       TableType = ttDefault, False, AList);
  972. end;
  973.  
  974. { TProcedureNameProperty }
  975.  
  976. type
  977.   TProcedureNameProperty = class(TDBStringProperty)
  978.   public
  979.     function AutoFill: Boolean; override;
  980.     procedure GetValueList(List: TStrings); override;
  981.   end;
  982.  
  983. function TProcedureNameProperty.AutoFill: Boolean;
  984. begin
  985.   Result := (GetComponent(0) as TDBDataSet).Active;
  986. end;
  987.  
  988. procedure TProcedureNameProperty.GetValueList(List: TStrings);
  989. var
  990.   DBDataSet: TDBDataSet;
  991. begin
  992.   DBDataSet := GetComponent(0) as TDBDataSet;
  993.   DBDataSet.DBSession.GetStoredProcNames(DBDataSet.DatabaseName, List);
  994. end;
  995. { TIndexFilesProperty }
  996.  
  997. type
  998.   TIndexFilesProperty = class(TPropertyEditor)
  999.   public
  1000.     function GetAttributes: TPropertyAttributes; override;
  1001.     procedure Edit; override;
  1002.     function GetValue: string; override;
  1003.   end;
  1004.  
  1005. function TIndexFilesProperty.GetAttributes: TPropertyAttributes;
  1006. begin
  1007.   Result := [paDialog, paReadOnly];
  1008. end;
  1009.  
  1010. function TIndexFilesProperty.GetValue: string;
  1011. begin
  1012.   Result := Format('(%s)', [TIndexFiles.ClassName]); { Do not localize }
  1013. end;
  1014.  
  1015. procedure TIndexFilesProperty.Edit;
  1016. var
  1017.   List: TStringList;
  1018.   Table: TTable;
  1019.   I: Integer;
  1020.   IndexFile: string;
  1021. begin
  1022.   Table := GetComponent(0) as TTable;
  1023.   List := TStringList.Create;
  1024.   try
  1025.     List.Assign(Table.IndexFiles);
  1026.     if EditIndexFiles(Table, List) then
  1027.     begin
  1028.       for I := 0 to List.Count - 1 do
  1029.       begin
  1030.         IndexFile := List[I];
  1031.         with Table.IndexFiles do
  1032.           if IndexOf(IndexFile) = -1 then Add(IndexFile);
  1033.       end;
  1034.       for I := Table.IndexFiles.Count - 1 downto 0 do
  1035.       begin
  1036.         IndexFile := Table.IndexFiles[I];
  1037.         with Table.IndexFiles do
  1038.           if List.IndexOf(IndexFile) = -1 then Delete(IndexOf(IndexFile));
  1039.       end;
  1040.       Modified;
  1041.     end;
  1042.   finally
  1043.     List.Free;
  1044.   end;
  1045. end;
  1046.  
  1047. { TUpdateSQLEditor }
  1048.  
  1049. type
  1050.   TUpdateSQLEditor = class(TComponentEditor)
  1051.   public
  1052.     procedure ExecuteVerb(Index: Integer); override;
  1053.     function GetVerb(Index: Integer): string; override;
  1054.     function GetVerbCount: Integer; override;
  1055.   end;
  1056.  
  1057. procedure TUpdateSQLEditor.ExecuteVerb(Index: Integer);
  1058. begin
  1059.   if EditUpdateSQL(TUpdateSQL(Component)) then Designer.Modified;
  1060. end;
  1061.  
  1062. function TUpdateSQLEditor.GetVerb(Index: Integer): string;
  1063. begin
  1064.   Result := SUpdateSQLEditor;
  1065. end;
  1066.  
  1067. function TUpdateSQLEditor.GetVerbCount: Integer;
  1068. begin
  1069.   Result := 1;
  1070. end;
  1071.  
  1072. { TTableFieldLinkProperty }
  1073.  
  1074. procedure TTableFieldLinkProperty.Edit;
  1075. var
  1076.   Table: TTable;
  1077. begin
  1078.   Table := DataSet as TTable;
  1079.   FTable := TTable.Create(nil);
  1080.   try
  1081.     FTable.SessionName := Table.SessionName;
  1082.     FTable.DatabaseName := Table.DatabaseName;
  1083.     FTable.TableName := Table.TableName;
  1084.     if Table.IndexFieldNames <> '' then
  1085.       FTable.IndexFieldNames := Table.IndexFieldNames else
  1086.       FTable.IndexName := Table.IndexName;
  1087.     FTable.MasterFields := Table.MasterFields;
  1088.     FTable.Open;
  1089.     inherited Edit;
  1090.     if Changed then
  1091.     begin
  1092.       Table.MasterFields := FTable.MasterFields;
  1093.       if FTable.IndexFieldNames <> '' then
  1094.         Table.IndexFieldNames := FTable.IndexFieldNames else
  1095.         Table.IndexName := FTable.IndexName;
  1096.     end;
  1097.   finally
  1098.     FTable.Free;
  1099.   end;
  1100. end;
  1101.  
  1102. procedure TTableFieldLinkProperty.GetFieldNamesForIndex(List: TStrings);
  1103. var
  1104.   i: Integer;
  1105. begin
  1106.   for i := 0 to FTable.IndexFieldCount - 1 do
  1107.     List.Add(FTable.IndexFields[i].FieldName);
  1108. end;
  1109.  
  1110. function TTableFieldLinkProperty.GetIndexBased: Boolean;
  1111. begin
  1112.   Result := not IProviderSupport(FTable).PSIsSQLBased;
  1113. end;
  1114.  
  1115. function TTableFieldLinkProperty.GetIndexDefs: TIndexDefs;
  1116. begin
  1117.   Result := FTable.IndexDefs;
  1118. end;
  1119.  
  1120. function TTableFieldLinkProperty.GetIndexFieldNames: string;
  1121. begin
  1122.   Result := FTable.IndexFieldNames;
  1123. end;
  1124.  
  1125. function TTableFieldLinkProperty.GetIndexName: string;
  1126. begin
  1127.   Result := FTable.IndexName;
  1128. end;
  1129.  
  1130. function TTableFieldLinkProperty.GetMasterFields: string;
  1131. begin
  1132.   Result := FTable.MasterFields;
  1133. end;
  1134.  
  1135. procedure TTableFieldLinkProperty.SetIndexFieldNames(const Value: string);
  1136. begin
  1137.   FTable.IndexFieldNames := Value;
  1138. end;
  1139.  
  1140. procedure TTableFieldLinkProperty.SetIndexName(const Value: string);
  1141. begin
  1142.   if Value = SPrimary then
  1143.     FTable.IndexName := '' else
  1144.     FTable.IndexName := Value;
  1145. end;
  1146.  
  1147. procedure TTableFieldLinkProperty.SetMasterFields(const Value: string);
  1148. begin
  1149.   FTable.MasterFields := Value;
  1150. end;
  1151.  
  1152.  
  1153.  
  1154. type
  1155.   TReportEditor = class(TComponentEditor)
  1156.   public
  1157.     procedure Edit; override;
  1158.     procedure ExecuteVerb(Index: Integer); override;
  1159.     function GetVerb(Index: Integer): string; override;
  1160.     function GetVerbCount: Integer; override;
  1161.   end;
  1162.  
  1163.   TReportDirProperty = class(TPropertyEditor)
  1164.   public
  1165.     function GetValue: string; override;
  1166.     procedure SetValue(const Value: string); override;
  1167.     function GetAttributes: TPropertyAttributes; override;
  1168.     procedure Edit; override;
  1169.   end;
  1170.  
  1171.   TReportNameProperty = class(TPropertyEditor)
  1172.   public
  1173.     function GetValue: string; override;
  1174.     procedure SetValue(const Value: string); override;
  1175.     function GetAttributes: TPropertyAttributes; override;
  1176.     procedure Edit; override;
  1177.   end;
  1178.  
  1179. { TReportEditor }
  1180.  
  1181. procedure TReportEditor.Edit;
  1182. begin
  1183.   TReport(Component).Run;
  1184. end;
  1185.  
  1186. procedure TReportEditor.ExecuteVerb(Index: Integer);
  1187. begin
  1188.   if Index = 0 then Edit;
  1189. end;
  1190.  
  1191. function TReportEditor.GetVerb(Index: Integer): string;
  1192. begin
  1193.   Result := SReportVerb;
  1194. end;
  1195.  
  1196. function TReportEditor.GetVerbCount: Integer;
  1197. begin
  1198.   Result := 1;
  1199. end;
  1200.  
  1201. { TReportDirProperty }
  1202.  
  1203. function TReportDirProperty.GetValue: string;
  1204. begin
  1205.   Result := (GetComponent(0) as TReport).ReportDir;
  1206. end;
  1207.  
  1208. procedure TReportDirProperty.SetValue(const Value: string);
  1209. begin
  1210.   (GetComponent(0) as TReport).ReportDir := Value;
  1211.   Modified;
  1212. end;
  1213.  
  1214. function TReportDirProperty.GetAttributes: TPropertyAttributes;
  1215. begin
  1216.   Result := [paDialog, paMultiSelect];
  1217. end;
  1218.  
  1219. procedure TReportDirProperty.Edit;
  1220. var
  1221.   FilePath: string;
  1222. begin
  1223.   FilePath := '';
  1224.   if SelectDirectory(FilePath, [], hcDSelectReportDir) then
  1225.   begin
  1226.     if AnsiLastChar(FilePath)^ <> '\' then FilePath := FilePath + '\';
  1227.     SetValue(FilePath);
  1228.   end;
  1229. end;
  1230.  
  1231. { TReportNameProperty }
  1232.  
  1233. function TReportNameProperty.GetValue: string;
  1234. begin
  1235.   Result := (GetComponent(0) as TReport).ReportName;
  1236. end;
  1237.  
  1238. procedure TReportNameProperty.SetValue(const Value: string);
  1239. begin
  1240.   (GetComponent(0) as TReport).ReportName := Value;
  1241.   Modified;
  1242. end;
  1243.  
  1244. function TReportNameProperty.GetAttributes: TPropertyAttributes;
  1245. begin
  1246.   Result := [paDialog, paMultiSelect];
  1247. end;
  1248.  
  1249. procedure TReportNameProperty.Edit;
  1250. var                                                       
  1251.   Dialog: TOpenDialog;
  1252.   FilePath: string;
  1253. begin
  1254.   Dialog := TOpenDialog.Create(nil);
  1255.   try
  1256.     with Dialog do
  1257.     begin
  1258.       DefaultExt := 'rpt';
  1259.       Filter := SReportFilter;
  1260.       if Execute then
  1261.         with GetComponent(0) as TReport do
  1262.         begin
  1263.           FileName := FileName;
  1264.           FilePath := ExtractFilePath(FileName);
  1265.           ReportDir := FilePath;
  1266.           ReportName := ExtractFileName(FileName);
  1267.           Modified;
  1268.         end;
  1269.     end;
  1270.   finally
  1271.     Dialog.Free;
  1272.   end;
  1273. end;
  1274.  
  1275.  
  1276. function SprigBDESessionName(const AName: string): string;
  1277. begin
  1278.   Result := AName;
  1279.   if (Result = '') or
  1280.      AnsiSameText(Result, Session.SessionName) then
  1281.     Result := cDefaultSessionSprigName;
  1282. end;
  1283.  
  1284. function SprigBDEImpliedDatabaseName(const AName: string): string;
  1285. begin
  1286.   Result := Format('%s.%s', [cImpliedDatabaseSprigPrefix, AName]); { do not localize }
  1287. end;
  1288.  
  1289. function SprigBDEImpliedSessionName(const AName: string): string;
  1290. begin
  1291.   Result := Format('%s.%s', [cImpliedSessionSprigPrefix, AName]); { do not localize }
  1292. end;
  1293.  
  1294. { TDBDataSetSprig }
  1295.  
  1296. function TDBDataSetSprig.AnyProblems: Boolean;
  1297. begin
  1298.   Result := inherited AnyProblems or
  1299.             (TDBDataSet(Item).DatabaseName = '');
  1300. end;
  1301.  
  1302. procedure TDBDataSetSprig.FigureParent;
  1303. var
  1304.   vSessionName: string;
  1305.   vSession, vDatabase: TSprig;
  1306. begin
  1307.   with TDBDataSet(Item) do
  1308.   begin
  1309.     // find real or default session
  1310.     vSessionName := SprigBDESessionName(SessionName);
  1311.     vSession := Root.Find(vSessionName, False);
  1312.  
  1313.     // if not found see if its the default session
  1314.     if (vSession = nil) and
  1315.        (vSessionName = cDefaultSessionSprigName) then
  1316.       vSession := Root.Add(TDefaultSessionSprig.Create(nil));
  1317.  
  1318.     // still not found, try for an implied session
  1319.     if vSession = nil then
  1320.     begin
  1321.       vSession := Root.Find(SprigBDEImpliedSessionName(SessionName), False);
  1322.  
  1323.       // if not make an implied session
  1324.       if vSession = nil then
  1325.       begin
  1326.         vSession := Root.Add(TImpliedSessionSprig.Create(nil));
  1327.         TImpliedSessionSprig(vSession).FSessionName := SessionName;
  1328.       end;
  1329.     end;
  1330.  
  1331.     // find data base under session
  1332.     vDatabase := vSession.Find(DatabaseName, False);
  1333.  
  1334.     // if not find a database alias
  1335.     if vDatabase = nil then
  1336.     begin
  1337.       vDatabase := vSession.Find(SprigBDEImpliedDatabaseName(DatabaseName), False);
  1338.  
  1339.       // if not make a database alias
  1340.       if vDatabase = nil then
  1341.       begin
  1342.         vDatabase := vSession.Add(TImpliedDatabaseSprig.Create(nil));
  1343.         TImpliedDatabaseSprig(vDatabase).FAlias := DatabaseName;
  1344.         TImpliedDatabaseSprig(vDatabase).FSessionName := SessionName;
  1345.       end;
  1346.     end;
  1347.  
  1348.     // set parent to the database
  1349.     vDatabase.Add(Self);
  1350.   end;
  1351. end;
  1352.  
  1353. function TDBDataSetSprig.DragDropTo(AItem: TSprig): Boolean;
  1354. begin
  1355.   if AItem is TImpliedDatabaseSprig then
  1356.   begin
  1357.     Result := not AnsiSameText(TImpliedDatabaseSprig(AItem).FAlias, TDBDataSet(Item).DatabaseName) or
  1358.               not AnsiSameText(TImpliedDatabaseSprig(AItem).FSessionName, TDBDataSet(Item).SessionName);
  1359.     if Result then
  1360.     begin
  1361.       TDBDataSet(Item).DatabaseName := TImpliedDatabaseSprig(AItem).FAlias;
  1362.       TDBDataSet(Item).SessionName := TImpliedDatabaseSprig(AItem).FSessionName;
  1363.     end;
  1364.   end
  1365.   else if AItem is TDatabaseSprig then
  1366.   begin
  1367.     Result := not AnsiSameText(TDatabase(AItem.Item).DatabaseName, TDBDataSet(Item).DatabaseName) or
  1368.               not AnsiSameText(TDatabase(AItem.Item).SessionName, TDBDataSet(Item).SessionName);
  1369.     if Result then
  1370.     begin
  1371.       TDBDataSet(Item).DatabaseName := TDatabase(AItem.Item).DatabaseName;
  1372.       TDBDataSet(Item).SessionName := TDatabase(AItem.Item).SessionName;
  1373.     end;
  1374.   end
  1375.   else
  1376.     Result := False;
  1377. end;
  1378.  
  1379. function TDBDataSetSprig.DragOverTo(AItem: TSprig): Boolean;
  1380. begin
  1381.   Result := ((AItem is TDatabaseSprig) and (TDatabase(AItem.Item).DatabaseName <> '')) or
  1382.             (AItem is TImpliedDatabaseSprig);
  1383. end;
  1384.  
  1385. class function TDBDataSetSprig.PaletteOverTo(AParent: TSprig; AClass: TClass): Boolean;
  1386. begin
  1387.   Result := ((AParent is TDatabaseSprig) and (TDatabase(AParent.Item).DatabaseName <> '')) or
  1388.             (AParent is TImpliedDatabaseSprig);
  1389. end;
  1390.  
  1391. procedure TDBDataSetSprig.Reparent;
  1392. begin
  1393.   if Parent is TDatabaseSprig then
  1394.     TDBDataSet(Item).SessionName := TDatabase(Parent.Item).SessionName
  1395.   else if Parent is TImpliedDatabaseSprig then
  1396.     TDBDataSet(Item).SessionName := TImpliedDatabaseSprig(Parent).FSessionName;
  1397. end;
  1398.  
  1399. { TSessionSprig }
  1400.  
  1401. function TSessionSprig.Name: string;
  1402. begin
  1403.   Result := TSession(Item).SessionName;
  1404. end;
  1405.  
  1406. function TSessionSprig.AnyProblems: Boolean;
  1407. begin
  1408.   Result := TSession(Item).SessionName = '';
  1409. end;
  1410.  
  1411. function TSessionSprig.Caption: string;
  1412. begin
  1413.   Result := CaptionFor(Name, UniqueName);
  1414. end;
  1415.  
  1416. { TDefaultSessionSprig }
  1417.  
  1418. function TDefaultSessionSprig.Caption: string;
  1419. begin
  1420.   Result := CaptionFor(Session.SessionName, Copy(Session.ClassName, 2, 255));
  1421. end;
  1422.  
  1423. function TDefaultSessionSprig.ItemClass: TClass;
  1424. begin
  1425.   Result := TSession;
  1426. end;
  1427.  
  1428. function TDefaultSessionSprig.UniqueName: string;
  1429. begin
  1430.   Result := cDefaultSessionSprigName;
  1431. end;
  1432.  
  1433. function TDefaultSessionSprig.Transient: Boolean;
  1434. begin
  1435.   Result := True;
  1436. end;
  1437.  
  1438. { TImpliedSessionSprig }
  1439.  
  1440. function TImpliedSessionSprig.Caption: string;
  1441. begin
  1442.   Result := CaptionFor(FSessionName, 'Implied Session'); { do not localize }
  1443. end;
  1444.  
  1445. function TImpliedSessionSprig.ItemClass: TClass;
  1446. begin
  1447.   Result := TSession;
  1448. end;
  1449.  
  1450. function TImpliedSessionSprig.UniqueName: string;
  1451. begin
  1452.   Result := SprigBDEImpliedSessionName(FSessionName);
  1453. end;
  1454.  
  1455. function TImpliedSessionSprig.Transient: Boolean;
  1456. begin
  1457.   Result := True;
  1458. end;
  1459.  
  1460. { TDatabaseSprig }
  1461.  
  1462. function TDatabaseSprig.Name: string;
  1463. begin
  1464.   Result := TDatabase(Item).DatabaseName;
  1465. end;
  1466.  
  1467. function TDatabaseSprig.AnyProblems: Boolean;
  1468. begin
  1469.   Result := TDatabase(Item).DatabaseName = '';
  1470. end;
  1471.  
  1472. function TDatabaseSprig.Caption: string;
  1473. var
  1474.   vName: string;
  1475. begin
  1476.   vName := Name;
  1477.   if TDatabase(Item).AliasName <> '' then
  1478.     Result := Format('%s:%s', [vName, TDatabase(Item).AliasName]); { Do not localize }
  1479.   Result := CaptionFor(vName, UniqueName);
  1480. end;
  1481.  
  1482. procedure TDatabaseSprig.FigureParent;
  1483. var
  1484.   vSessionName: string;
  1485.   vSession: TSprig;
  1486. begin
  1487.   with TDatabase(Item) do
  1488.   begin
  1489.     // find real or default session
  1490.     vSessionName := SprigBDESessionName(SessionName);
  1491.     vSession := Root.Find(vSessionName, False);
  1492.  
  1493.     // if not found see if its the default session
  1494.     if (vSession = nil) and
  1495.        (vSessionName = cDefaultSessionSprigName) then
  1496.       vSession := Root.Add(TDefaultSessionSprig.Create(nil));
  1497.  
  1498.     // still not found, try for an implied session
  1499.     if vSession = nil then
  1500.     begin
  1501.       vSession := Root.Find(SprigBDEImpliedSessionName(SessionName), False);
  1502.  
  1503.       // if not make an implied session
  1504.       if vSession = nil then
  1505.       begin
  1506.         vSession := Root.Add(TImpliedSessionSprig.Create(nil));
  1507.         TImpliedSessionSprig(vSession).FSessionName := SessionName;
  1508.       end;
  1509.     end;
  1510.  
  1511.     // well put it
  1512.     vSession.Add(Self);
  1513.   end;
  1514. end;
  1515.  
  1516. function TDatabaseSprig.DragDropTo(AItem: TSprig): Boolean;
  1517. begin
  1518.   if AItem is TSessionSprig then
  1519.   begin
  1520.     Result := not AnsiSameText(TSession(AItem.Item).SessionName, TDatabase(Item).SessionName);
  1521.     if Result then
  1522.       TDatabase(Item).SessionName := TSession(AItem.Item).SessionName;
  1523.   end
  1524.   else if AItem is TImpliedSessionSprig then
  1525.   begin
  1526.     Result := not AnsiSameText(TImpliedSessionSprig(AItem).FSessionName, TDatabase(Item).SessionName);
  1527.     if Result then
  1528.       TDatabase(Item).SessionName := TImpliedSessionSprig(AItem).FSessionName;
  1529.   end
  1530.   else if AItem is TDefaultSessionSprig then
  1531.   begin
  1532.     Result := not AnsiSameText(TDatabase(Item).SessionName, Session.SessionName) or
  1533.               (TDatabase(Item).SessionName <> '');
  1534.     if Result then
  1535.       TDatabase(Item).SessionName := '';
  1536.   end
  1537.   else
  1538.     Result := False;
  1539.   ReparentChildren;
  1540. end;
  1541.  
  1542. function TDatabaseSprig.DragOverTo(AItem: TSprig): Boolean;
  1543. begin
  1544.   Result := ((AItem is TSessionSprig) and (TSession(AItem.Item).SessionName <> '')) or
  1545.             (AItem is TImpliedSessionSprig) or
  1546.             (AItem is TDefaultSessionSprig);
  1547. end;
  1548.  
  1549. class function TDatabaseSprig.PaletteOverTo(AParent: TSprig; AClass: TClass): Boolean;
  1550. begin
  1551.   Result := ((AParent is TSessionSprig) and (TSession(AParent.Item).SessionName <> '')) or
  1552.             (AParent is TImpliedSessionSprig) or
  1553.             (AParent is TDefaultSessionSprig);
  1554. end;
  1555.  
  1556. { TImpliedDatabaseSprig }
  1557.  
  1558. function TImpliedDatabaseSprig.AnyProblems: Boolean;
  1559. begin
  1560.   Result := FAlias = '';
  1561. end;
  1562.  
  1563. function TImpliedDatabaseSprig.Caption: string;
  1564. begin
  1565.   Result := CaptionFor(FAlias, 'Alias'); { Do not localize }
  1566. end;
  1567.  
  1568. function TImpliedDatabaseSprig.DragDropTo(AItem: TSprig): Boolean;
  1569. begin
  1570.   if AItem is TSessionSprig then
  1571.   begin
  1572.     Result := not AnsiSameText(TSession(AItem.Item).SessionName, FSessionName);
  1573.     if Result then
  1574.       FSessionName := TSession(AItem.Item).SessionName;
  1575.   end
  1576.   else if AItem is TImpliedSessionSprig then
  1577.   begin
  1578.     Result := not AnsiSameText(TImpliedSessionSprig(AItem).FSessionName, FSessionName);
  1579.     if Result then
  1580.       FSessionName := TImpliedSessionSprig(AItem).FSessionName;
  1581.   end
  1582.   else if AItem is TDefaultSessionSprig then
  1583.   begin
  1584.     Result := not AnsiSameText(TDatabase(Item).SessionName, Session.SessionName) or
  1585.               (TDatabase(Item).SessionName <> '');
  1586.     if Result then
  1587.       TDatabase(Item).SessionName := '';
  1588.   end
  1589.   else
  1590.     Result := False;
  1591.   Reparent;
  1592. end;
  1593.  
  1594. function TImpliedDatabaseSprig.DragOverTo(AItem: TSprig): Boolean;
  1595. begin
  1596.   Result := (AItem is TSessionSprig) or
  1597.             (AItem is TImpliedSessionSprig) or
  1598.             (AItem is TDefaultSessionSprig);
  1599. end;
  1600.  
  1601. procedure TImpliedDatabaseSprig.FigureParent;
  1602. var
  1603.   vSessionName: string;
  1604.   vSession: TSprig;
  1605. begin
  1606.   // find real or default session
  1607.   vSessionName := SprigBDESessionName(FSessionName);
  1608.   vSession := Root.Find(vSessionName, False);
  1609.  
  1610.   // if not found see if its the default session
  1611.   if (vSession = nil) and
  1612.      (vSessionName = cDefaultSessionSprigName) then
  1613.     vSession := Root.Add(TDefaultSessionSprig.Create(nil));
  1614.  
  1615.   // still not found, try for an implied session
  1616.   if vSession = nil then
  1617.   begin
  1618.     vSession := Root.Find(SprigBDEImpliedSessionName(FSessionName), False);
  1619.  
  1620.     // if not make an implied session
  1621.     if vSession = nil then
  1622.     begin
  1623.       vSession := Root.Add(TImpliedSessionSprig.Create(nil));
  1624.       TImpliedSessionSprig(vSession).FSessionName := FSessionName;
  1625.     end;
  1626.   end;
  1627.  
  1628.   // put ourself here
  1629.   vSession.Add(Self);
  1630. end;
  1631.  
  1632. function TImpliedDatabaseSprig.ItemClass: TClass;
  1633. begin
  1634.   Result := TDatabase;
  1635. end;
  1636.  
  1637. function TImpliedDatabaseSprig.UniqueName: string;
  1638. begin
  1639.   Result := SprigBDEImpliedDatabaseName(FAlias);
  1640. end;
  1641.  
  1642. function TImpliedDatabaseSprig.Transient: Boolean;
  1643. begin
  1644.   Result := True;
  1645. end;
  1646.  
  1647. { TNestedTableSprig }
  1648.  
  1649. class function TNestedTableSprig.ParentProperty: string;
  1650. begin
  1651.   Result := 'DataSetField'; { do not localize }
  1652. end;
  1653.  
  1654. { TTableSprig }
  1655.  
  1656. function TTableSprig.AnyProblems: Boolean;
  1657. begin
  1658.   Result := inherited AnyProblems or
  1659.             (TTable(Item).TableName = '');
  1660. end;
  1661.  
  1662. function TTableSprig.Caption: string;
  1663. begin
  1664.   Result := CaptionFor(TTable(Item).TableName, UniqueName);
  1665. end;
  1666.  
  1667. { TQuerySprig }
  1668.  
  1669. function TQuerySprig.AnyProblems: Boolean;
  1670. begin
  1671.   Result := inherited AnyProblems or
  1672.             (TQuery(Item).SQL.Count = 0);
  1673. end;
  1674.  
  1675. { TStoredProcSprig }
  1676.  
  1677. function TStoredProcSprig.AnyProblems: Boolean;
  1678. begin
  1679.   Result := inherited AnyProblems or
  1680.             (TStoredProc(Item).StoredProcName = '');
  1681. end;
  1682.  
  1683. function TStoredProcSprig.Caption: string;
  1684. begin
  1685.   Result := CaptionFor(TStoredProc(Item).StoredProcName, UniqueName);
  1686. end;
  1687.  
  1688. { TTableMasterDetailBridge }
  1689.  
  1690. class function TTableMasterDetailBridge.GetOmegaSource(
  1691.   AItem: TPersistent): TDataSource;
  1692. begin
  1693.   Result := TTable(AItem).MasterSource;
  1694. end;
  1695.  
  1696. class function TTableMasterDetailBridge.OmegaIslandClass: TIslandClass;
  1697. begin
  1698.   Result := TTableIsland;
  1699. end;
  1700.  
  1701. class procedure TTableMasterDetailBridge.SetOmegaSource(AItem: TPersistent;
  1702.   ADataSource: TDataSource);
  1703. begin
  1704.   TTable(AItem).MasterSource := ADataSource;
  1705. end;
  1706.  
  1707. function TTableMasterDetailBridge.CanEdit: Boolean;
  1708. begin
  1709.   Result := True;
  1710. end;
  1711.  
  1712. function TTableMasterDetailBridge.Edit: Boolean;
  1713. var
  1714.   vPropEd: TTableFieldLinkProperty;
  1715. begin
  1716.   vPropEd := TTableFieldLinkProperty.CreateWith(TDataSet(Omega.Item));
  1717.   try
  1718.     vPropEd.Edit;
  1719.     Result := vPropEd.Changed;
  1720.   finally
  1721.     vPropEd.Free;
  1722.   end;
  1723. end;
  1724.  
  1725. function TTableMasterDetailBridge.Caption: string;
  1726. begin
  1727.   if TTable(Omega.Item).MasterFields = '' then
  1728.     Result := SNoMasterFields
  1729.   else
  1730.     Result := TTable(Omega.Item).MasterFields;
  1731. end;
  1732.  
  1733. { TQueryMasterDetailBridge }
  1734.  
  1735. function TQueryMasterDetailBridge.Caption: string;
  1736. begin
  1737.   Result := SParamsFields;
  1738. end;
  1739.  
  1740. class function TQueryMasterDetailBridge.GetOmegaSource(
  1741.   AItem: TPersistent): TDataSource;
  1742. begin
  1743.   Result := TQuery(AItem).DataSource;
  1744. end;
  1745.  
  1746. class function TQueryMasterDetailBridge.OmegaIslandClass: TIslandClass;
  1747. begin
  1748.   Result := TQueryIsland;
  1749. end;
  1750.  
  1751. class function TQueryMasterDetailBridge.RemoveMasterFieldsAsWell: Boolean;
  1752. begin
  1753.   Result := False;
  1754. end;
  1755.  
  1756. class procedure TQueryMasterDetailBridge.SetOmegaSource(AItem: TPersistent;
  1757.   ADataSource: TDataSource);
  1758. begin
  1759.   TQuery(AItem).DataSource := ADataSource;
  1760. end;
  1761.  
  1762. { TBatchMoveSprig }
  1763.  
  1764. function TBatchMoveSprig.AnyProblems: Boolean;
  1765. begin
  1766.   Result := (TBatchMove(Item).Destination = nil) or
  1767.             (TBatchMove(Item).Source = nil);
  1768. end;
  1769.  
  1770. function TBatchMoveSprig.Caption: string;
  1771. var
  1772.   vFrom, vTo: string;
  1773. begin
  1774.   if TBatchMove(Item).Source <> nil then
  1775.     vFrom := TBatchMove(Item).Source.Name
  1776.   else
  1777.     vFrom := '?';
  1778.   if TBatchMove(Item).Destination <> nil then
  1779.     vTo := TBatchMove(Item).Destination.Name
  1780.   else
  1781.     vTo := '?';
  1782.   Result := CaptionFor(Format('%s -> %s', [vFrom, vTo]), UniqueName); { do not localize }
  1783. end;
  1784.  
  1785. { TUpdateSQLSprig }
  1786.  
  1787. function TUpdateSQLSprig.AnyProblems: Boolean;
  1788. begin
  1789.   with TUpdateSQL(Item) do
  1790.     Result := (ModifySQL.Count = 0) and
  1791.               (InsertSQL.Count = 0) and
  1792.               (DeleteSQL.Count = 0);
  1793. end;
  1794.  
  1795. procedure Register;
  1796. begin
  1797.   { Database Components are excluded from the STD SKU }
  1798.   if GDAL <> LongWord(-16) then
  1799.   begin
  1800.     RegisterComponents(srDAccess, [TTable, TQuery, TStoredProc, TDatabase,
  1801.       TSession, TBatchMove, TUpdateSQL]);
  1802.     { Components that are excluded from the STD & PRO SKUs }
  1803.     if GDAL = 0 then
  1804.       RegisterComponents(srDAccess, [TNestedTable]);
  1805.     RegisterPropertyEditor(TypeInfo(string), TDatabase, 'AliasName', TAliasNameProperty);
  1806.     RegisterPropertyEditor(TypeInfo(string), TDatabase, 'DriverName', TDriverNameProperty);
  1807.     RegisterPropertyEditor(TypeInfo(string), TDatabase, 'SessionName', TSessionNameProperty);
  1808.     RegisterPropertyEditor(TypeInfo(string), TDBDataSet, 'SessionName', TSessionNameProperty);
  1809.     RegisterPropertyEditor(TypeInfo(string), TDBDataSet, 'DatabaseName', TDatabaseNameProperty);
  1810.     RegisterPropertyEditor(TypeInfo(TDataSetUpdateObject), TDataSet, 'UpdateObject', TComponentProperty);
  1811.     RegisterPropertyEditor(TypeInfo(TFileName), TTable, 'TableName', TTableNameProperty);
  1812.     RegisterPropertyEditor(TypeInfo(string), TTable, 'IndexName', TIndexNameProperty);
  1813.     RegisterPropertyEditor(TypeInfo(string), TTable, 'IndexFieldNames', TIndexFieldNamesProperty);
  1814.     RegisterPropertyEditor(TypeInfo(string), TTable, 'MasterFields', TTableFieldLinkProperty);
  1815.     RegisterPropertyEditor(TypeInfo(string), TStoredProc, 'StoredProcName', TProcedureNameProperty);
  1816.     RegisterPropertyEditor(TypeInfo(TParams), TQuery, 'Params', TQueryParamsProperty);
  1817.     RegisterPropertyEditor(TypeInfo(TParams), TStoredProc, 'Params', TStoredProcParamsProperty);
  1818.     RegisterPropertyEditor(TypeInfo(TStrings), TTable, 'IndexFiles', TIndexFilesProperty);
  1819.     RegisterPropertyEditor(TypeInfo(TCheckConstraints), TDBDataSet, 'Constraints', TCheckConstraintsProperty);
  1820.     RegisterComponentEditor(TDBDataset, TDBDataSetEditor);
  1821.     RegisterComponentEditor(TTable, TTableEditor);
  1822.     RegisterComponentEditor(TDatabase, TDatabaseEditor);
  1823.     RegisterComponentEditor(TBatchMove, TBatchMoveEditor);
  1824.     RegisterComponentEditor(TQuery, TQueryEditor);
  1825.     RegisterComponentEditor(TStoredProc, TStoredProcEditor);
  1826.     RegisterComponentEditor(TUpdateSQL, TUpdateSQLEditor);
  1827.  
  1828.     { Obsolete Components }
  1829.     {$IFNDEF DEVELOPERS}
  1830.       if HexDisplayPrefix = '$' then  // Only register TReport for Delphi
  1831.       begin
  1832.         RegisterComponents(srDAccess, [TReport]);
  1833.         RegisterPropertyEditor(TypeInfo(string), TReport, 'ReportDir', TReportDirProperty);
  1834.         RegisterPropertyEditor(TypeInfo(string), TReport, 'ReportName', TReportNameProperty);
  1835.         RegisterComponentEditor(TReport, TReportEditor);
  1836.       end;
  1837.       RegisterComponents(srWin31, [TDBLookupList, TDBLookupCombo]);
  1838.       RegisterNonActiveX([TDBLookupList, TDBLookupCombo], axrIncludeDescendants);
  1839.     {$ENDIF}
  1840.  
  1841.     { Property Category registration }
  1842.     RegisterPropertiesInCategory(TDatabaseCategory, TDBDataSet,
  1843.       ['DatabaseName', 'SessionName']);
  1844.  
  1845.     RegisterPropertiesInCategory(TDatabaseCategory, TDatabase,
  1846.       ['AliasName', 'DriverName', 'SessionName', 'DatabaseName']);
  1847.  
  1848.     { Property Category registration }
  1849.     RegisterPropertiesInCategory(TDatabaseCategory, TDataSetUpdateObject, ['*SQL']);
  1850.  
  1851.     RegisterSprigType(TSession, TSessionSprig);
  1852.     RegisterSprigType(TDatabase, TDatabaseSprig);
  1853.     RegisterSprigType(TNestedTable, TNestedTableSprig);
  1854.     RegisterSprigType(TBDEDataSet, TBDEDataSetSprig);
  1855.     RegisterSprigType(TDBDataSet, TDBDataSetSprig);
  1856.     RegisterSprigType(TTable, TTableSprig);
  1857.     RegisterSprigType(TQuery, TQuerySprig);
  1858.     RegisterSprigType(TStoredProc, TStoredProcSprig);
  1859.     RegisterSprigType(TBatchMove, TBatchMoveSprig);
  1860.     RegisterSprigType(TUpdateSQL, TUpdateSQLSprig);
  1861.  
  1862.     RegisterIslandType(TBDEDataSetSprig, TBDEDataSetIsland);
  1863.     RegisterIslandType(TDBDataSetSprig, TDBDataSetIsland);
  1864.     RegisterIslandType(TTableSprig, TTableIsland);
  1865.     RegisterIslandType(TQuerySprig, TQueryIsland);
  1866.  
  1867.     RegisterBridgeType(TDataSetIsland, TTableIsland, TTableMasterDetailBridge);
  1868.     //RegisterBridgeType(TDataSourceIsland, TTableIsland, TTableMasterDetailBridge);
  1869.     RegisterBridgeType(TDataSetIsland, TQueryIsland, TQueryMasterDetailBridge);
  1870.     //RegisterBridgeType(TDataSourceIsland, TQueryIsland, TQueryMasterDetailBridge);
  1871.   end;
  1872. end;
  1873.  
  1874. { TBDEDataSetSprig }
  1875.  
  1876. function TBDEDataSetSprig.GetDSDesignerClass: TDSDesignerClass;
  1877. begin
  1878.   Result := TBDEDesigner;
  1879. end;
  1880.  
  1881. end.
  1882.